#pragma once

class CKtvHttpClient
{
public:
	CKtvHttpClient(void);
	~CKtvHttpClient(void);
	BOOL OpenHost( const char* host, u_short port, HWND  hWnd, UINT nMsg );
	void Close( );

	BOOL PostRequest(const char* lpUri, DWORD  dwTimeout = 1000);
	BOOL PostRequest(LPCTSTR lpUri, DWORD  dwTimeout = 1000);
	int OnSocketMsg( WPARAM wParam, LPARAM lParam );

	string GetContent(void);

	BOOL IsReadable(void);

	BOOL IsWriteable(void);

protected:

	BOOL ConnectHost( );
	BOOL SendRequest( const char* lpUri );
	BOOL RecvContent( void );
	BOOL ParserContent( void );

	
	sockaddr_in serverAddr;
	
	string  m_strContent;
	SOCKET m_sckClient;

	HWND  m_hWnd;
	UINT  m_nMsg;
	string  m_strHost;
	u_short m_nPort;

	int m_iStatus;

	std::string m_strReceiveBuf;
	DWORD  m_dwContentLength;

};

